package aduros.net {

import flash.utils.ByteArray;

import com.whirled.net.MessageSubControl;

public class RemoteCaller
{
    public function RemoteCaller (ctrl :MessageSubControl, serviceName :String)
    {
        _ctrl = ctrl;
        _serviceName = serviceName;
    }

    public function apply (handler :String, ... args) :void
    {
        var ba :ByteArray = new ByteArray();

        ba.writeUTF(handler);
        ba.writeInt(args.length);
        for each (var arg :Object in args) {
            ba.writeObject(arg);
        }

        _ctrl.sendMessage(_serviceName, ba);
    }

    protected var _ctrl :MessageSubControl;
    protected var _serviceName :String;
}

}
